<template>
  <!-- 登录 -->
  <div>
    <van-field v-model="account" label="账号" placeholder="账号" />
    <van-field
      v-model="password"
      type="password"
      label="密码"
      placeholder="请输入密码"
    />
    <van-field v-model="name" label="姓名" placeholder="账号" />
    <van-field v-model="mobile" label="手机号" placeholder="账号" />

    <br /><br />
    <van-button type="primary" @click="submit">注册</van-button>
  </div>
</template>

<script>
import { ref } from '@vue/reactivity';
export default {
  setup(){
    const value1 = ref(0);
    const option1 = [
      {text: "班级", value: 0}
    ]
  },
  data() {
    return {
      account: "",
      password: "",
      name: "",
      mobile: "",
      classs_id: "",
      user_id: "",
      role_id: "",
    };
  },
  methods: {
    submit: function () {
      if (this.account == "") {
        this.$toast.fail("账号不能为空");
        return false;
      }
      if (this.password == "") {
        this.$toast.fail("密码不能为空");
        return false;
      }
      if (this.name == "") {
        this.$toast.fail("姓名不能为空");
        return false;
      }
      if (this.mobile == "") {
        this.$toast.fail("手机号不能为空");
        return false;
      }
      this.myaxios(this.weburl + "user/register/", "post", {
        account: this.account,
        password: this.password,
        name: this.name,
        mobile: this.mobile,
        classs_id: this.classs_id,
        user_id: this.user_id,
        role_id: this.role_id,
      }).then((res) => {
        console.log("res", res);
        if (res.code == 200) {
          this.$toast.success(res.msg);
        } else {
          this.$toast.fail(data.msg);
        }
      });
    },
  },
  created() {},
};
</script>

<style scoped>
</style>